home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / game / shoot / ADoom_src_1_2.lha / ADoom_src / amiga_main.c < prev    next >
C/C++ Source or Header  |  1998-03-08  |  5KB  |  209 lines

  1. // Emacs style mode select   -*- C++ -*- 
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // $Log:$
  18. //
  19. // DESCRIPTION:
  20. //    Main program, simply calls D_DoomMain high level loop.
  21. //
  22. //-----------------------------------------------------------------------------
  23.  
  24. const char amigaversion[] = "$VER: ADoom 1.2 " __AMIGADATE__ ;
  25.  
  26. long __oslibversion = 38;    /* we require at least OS3.0 for LoadRGB32() */
  27. char __stdiowin[] = "CON:20/50/500/130/ADoom";
  28. char __stdiov37[] = "/AUTO/CLOSE/WAIT";
  29.  
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32.  
  33. #include <exec/exec.h>
  34. #include <workbench/startup.h>
  35. #include <workbench/workbench.h>
  36. #include <workbench/icon.h>
  37.  
  38. #include <proto/exec.h>
  39. #include <proto/icon.h>
  40.  
  41. #include "doomdef.h"
  42.  
  43. #include "m_argv.h"
  44. #include "d_main.h"
  45. #include "i_system.h"
  46. #include "m_fixed.h"
  47.  
  48. /**********************************************************************/
  49. extern struct ExecBase *SysBase;
  50.  
  51. int VERSION = 110;
  52.  
  53. int cpu_type;
  54.  
  55. /**********************************************************************/
  56. int main (int argc, char* argv[])
  57.   struct WBStartup *argmsg;
  58.   struct WBArg *wb_arg;
  59.   struct DiskObject *obj;
  60.   char **toolarray, *s;
  61.   int i, p;
  62.  
  63.   /* these command line arguments are flags */
  64.   static char *flags[] = {
  65.     "-forcedemo",
  66.     "-changepitch",
  67.     "-mouse",
  68.     "-joypad",
  69.     "-music",
  70.     "-nosfx",
  71.     "-mmu",
  72.     "-fps",
  73.     "-rotatemap",
  74.     "-maponhu",
  75.     "-rtg",
  76.     "-native",
  77.     "-ehb",
  78.     "-mousepointer",
  79.     "-sega3",
  80.     "-sega6",
  81.     "-pcchecksum",
  82.     "-directcgx",
  83.     "-graffiti",
  84.     "-graffiti2",
  85.     "-rawkey",
  86.     "-maxdemo",
  87.     "-nodraw",
  88.     "-noblit",
  89.     "-debugfile",
  90.     "-shdev",
  91.     "-regdev",
  92.     "-comdev",
  93.     "-nomonsters",
  94.     "-respawn",
  95.     "-fast",
  96.     "-devparm",
  97.     "-altdeath",
  98.     "-deathmatch",
  99.     "-cdrom",
  100.     "-playdemo",
  101.     "-avg"
  102.   };
  103.   /* these command line arguments each take a value */
  104.   static char *settings[] = {
  105.     "-screenmode",
  106.     "-taskpriority",
  107.     "-heapsize",
  108.     "-cpu",
  109.     "-forceversion",
  110.     "-width",
  111.     "-height",
  112.     "-file",
  113.     "-deh",
  114.     "-timedemo",
  115.     "-skill",
  116.     "-episode",
  117.     "-timer",
  118.     "-statcopy",
  119.     "-record",
  120.     "-playdemo",
  121.     "-timedemo",
  122.     "-loadgame",
  123.     "-config"
  124.     "-turbo",
  125.   };
  126.  
  127.   printf ("%s\n", &amigaversion[6]);
  128.  
  129.   myargc = argc;
  130.   if ((myargv = malloc(sizeof(char *)*MAXARGVS)) == NULL)
  131.     I_Error ("malloc(%d) failed", sizeof(char *)*MAXARGVS);
  132.   memset (myargv, 0, sizeof(char *)*MAXARGVS);
  133.   memcpy (myargv, argv, sizeof(char *)*myargc);
  134.  
  135.   /* parse icon tooltypes and convert them to argc/argv format */
  136.   if (argc == 0) {
  137.     argmsg = (struct WBStartup *)argv;
  138.     wb_arg = argmsg->sm_ArgList;
  139.     if ((myargv[myargc] = malloc(strlen(wb_arg->wa_Name)+1)) == NULL)
  140.       I_Error ("malloc(%d) failed", strlen(wb_arg->wa_Name)+1);
  141.     strcpy (myargv[myargc++], wb_arg->wa_Name);
  142.   }
  143.   if ((obj = GetDiskObject (myargv[0])) != NULL) {
  144.     toolarray = obj->do_ToolTypes;
  145.     for (i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) {
  146.       if (FindToolType (toolarray, &flags[i][1]) != NULL) {
  147.         myargv[myargc++] = flags[i];
  148.       }
  149.     }
  150.     for (i = 0; i < sizeof(settings)/sizeof(settings[0]); i++) {
  151.       if ((s = FindToolType (toolarray, &settings[i][1])) != NULL) {
  152.         myargv[myargc++] = settings[i];
  153.         if ((myargv[myargc] = malloc(strlen(s)+1)) == NULL)
  154.           I_Error ("malloc(%d) failed", strlen(s)+1);
  155.         strcpy(myargv[myargc++], s);
  156.       }
  157.     }
  158.     FreeDiskObject (obj);
  159.   }
  160.  
  161.   if (argc != myargc) {
  162.     printf ("\nIcon tooltypes translated command line to:\n\n    ");
  163.     for (i = 0; i < myargc; i++)
  164.       printf (" %s", myargv[i]);
  165.     printf ("\n\n");
  166.   }
  167.  
  168.   if ((SysBase->AttnFlags & AFF_68060) != 0)
  169.     cpu_type = 68060;
  170.   else if ((SysBase->AttnFlags & AFF_68040) != 0)
  171.     cpu_type = 68040;
  172.   else if ((SysBase->AttnFlags & AFF_68030) != 0)
  173.     cpu_type = 68030;
  174.   else if ((SysBase->AttnFlags & AFF_68020) != 0)
  175.     cpu_type = 68020;
  176.   else if ((SysBase->AttnFlags & AFF_68010) != 0)
  177.     cpu_type = 68010;
  178.   else
  179.     cpu_type = 68000;
  180.  
  181.   p = M_CheckParm ("-cpu");
  182.   if (p && p < myargc - 1) {
  183.     cpu_type = atoi (myargv[p+1]);
  184.   }
  185.  
  186.   if (cpu_type >= 68060) {
  187.     if ((SysBase->AttnFlags & AFB_68881) != 0) {
  188.       SetFPMode ();  /* set FPU rounding mode to "trunc towards -infinity" */
  189.       FixedMul = FixedMul_060fpu;
  190.       FixedDiv = FixedDiv_060fpu;
  191.     } else {
  192.       FixedMul = FixedMul_060;
  193.       FixedDiv = FixedDiv_040;
  194.     }
  195.   } else {
  196.     FixedMul = FixedMul_040;
  197.     FixedDiv = FixedDiv_040;
  198.   }
  199.  
  200.   p = M_CheckParm ("-forceversion");
  201.   if (p && p < myargc - 1)
  202.     VERSION = atoi (myargv[p+1]);
  203.  
  204.   D_DoomMain ();
  205.  
  206.   return 0;
  207. }
  208.